package cn.tedu.home1ess.admin.content.controller;

import cn.tedu.common.response.JsonResult;
import cn.tedu.common.web.PageDataVO;
import cn.tedu.home1ess.admin.content.pojo.param.PictureParam;
import cn.tedu.home1ess.admin.content.pojo.vo.DetailPictureVO;
import cn.tedu.home1ess.admin.content.service.IVerificationDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/verification" )
@Validated
@Api(tags = "房屋详情接口")
public class VerificationController {
    @Autowired
    private IVerificationDetailService verificationDetailService;

    @GetMapping("picture")
    @ApiOperation("获取全部房屋的图片")
    //todo 需要拿到token中的Userid
    public JsonResult listForPicture(@RequestParam Integer pageSize,
                                     @RequestParam Integer currentPage){
        PageDataVO<DetailPictureVO> list=verificationDetailService.listForPicture(pageSize, currentPage);
        return JsonResult.ok(list);
    }

    @PostMapping("add-picture")
    @ApiOperation("上传图片")
    public JsonResult addPictureById(PictureParam pictureParam){
        verificationDetailService.addPictureById(pictureParam);
        return JsonResult.ok();
    }

    @PostMapping("delete")
    @ApiOperation("删除图片")
   public JsonResult deletePictureById(PictureParam pictureParam){
        verificationDetailService.deletePictureById(pictureParam);
        return JsonResult.ok();
    }
}
